
#include "UserRecord.h"

namespace AirlineRes
{

UserRecord::UserRecord
(
  std::string const& _username,
  std::string const& _password,
  bool _isAdmin
)
  : m_username( _username ),
    m_password( _password ),
    m_isAdmin( _isAdmin )
{
}

Record::RecordIOResult UserRecord::LoadRecord( std::istream& _stream )
{
  // TODO: Validation and error handling.
  _stream >> std::skipws;   // Skip whitespace.
  _stream >> m_id >> m_username >> m_password >> m_isAdmin;
  _stream >> std::noskipws; // Reset stream state. 

  return Record::RecordIOResult_Success;
}

Record::RecordIOResult UserRecord::WriteRecord( std::ostream& _stream ) const
{
  _stream
    << m_id << " "
    << m_username << " "
    << m_password << " "
    << (int)m_isAdmin << "\n";

   return Record::RecordIOResult_Success;
}
    

} // namespace AirlineRes
